package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerCostEstimation;
import com.shrcl.engineerprocess.domain.EngineerProject;
import com.shrcl.engineerprocess.domain.EngineerProjectDAO;
import com.shrcl.engineerprocess.domain.impl.EngineerProjectImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.EngineerProjectDAO")
public class EngineerProjectDAOImpl extends BaseDAOService<EngineerProject> implements EngineerProjectDAO {
  public EngineerProject create(final Procedure1<? super EngineerProject> init) {EngineerProject engineerProject=EngineerProjectImpl.create(getObjectFactory());
    final Procedure1<EngineerProject> _function = new Procedure1<EngineerProject>() {
        public void apply(final EngineerProject it) {
          init.apply(it);
        }
      };
    EngineerProject _doubleArrow = ObjectExtensions.<EngineerProject>operator_doubleArrow(engineerProject, _function);
    return _doubleArrow;
  }
  
  public void delete(final EngineerProject engineerProject) {getObjectFactory().delete(engineerProject);
    
  }
  
  public EngineerProject findEngineerProject(final EngineerCostEstimation engineerCostEstimation) {
    IGenericQuery<EngineerProject> query=getObjectFactory().createGenericQuery(EngineerProject.class,"select e from com.shrcl.engineerprocess.domain.impl.EngineerProjectImpl as e   where ((e.tscCostEstimation) = (:engineerCostEstimation)) and  e.active = 1      ").setParameter("engineerCostEstimation",engineerCostEstimation);
    EngineerProject _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
}
